import 'package:flutter/material.dart';

// 测试平台菜单 OK
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      body: TestMenuScreen(),
    ));
  }
}

class TestMenuScreen extends StatefulWidget {
  const TestMenuScreen({super.key});

  @override
  State<TestMenuScreen> createState() => _TestMenuScreenState();
}

class _TestMenuScreenState extends State<TestMenuScreen> {
  @override
  Widget build(BuildContext context) {
    return PlatformMenuBar(menus: [
      PlatformMenu(label: '菜单1', menus: [
        PlatformMenuItemGroup(members: [
          PlatformMenuItem(label: "测试1",onSelected: (){
            print("测试1");
          }),
          PlatformMenuItem(label: "测试2")
        ])
      ]),
      PlatformMenu(label: '菜单2', menus: [
        PlatformMenuItemGroup(members: [
          PlatformMenuItem(label: "测试3"),
          PlatformMenuItem(label: "测试4")
        ])
      ]),
    ], child: Center(child: Text("测试")));
  }
}
